using UseCaseManager.BO;
using NUnit.Framework;

namespace UseCaseManager.Test.BO
{
    /// <summary>
    /// Provides a place to write custom tests for UseCase objects.
    /// This file is only written once and can be changed.  The Def file
    /// attached to this as a dependent is rewritten with each regeneration
    /// and contains the standard tests for UseCase.
    /// Regenerate this test project whenever there have been changes to the
    /// business objects.
    /// If tests are failing due to a unique setup in your application,
    /// you can either override the Create methods in TestUtils, or you
    /// can add the test to the ignore list below and reimplement it here.
    /// </summary>
    public partial class TestUseCase
    {
        [TestFixtureSetUp]
        public void SetupTestFixture()
        {
            //------------------------------------------------------------
            // Use this list to ignore generated tests that are failing
            // due to a unique condition in your application.
            // Remember to reimplement the test here.
            //------------------------------------------------------------
            //_ignoreList.Add("TestMethodName", "Reason for ignoring it");
            base.TestFixtureSetup();
        }
        
       [Test]
        public void Test_SetBaseline_UseCase_DoesNotBelongToDrop()
        {
            //---------------Set up test pack-------------------
            UseCase useCase = TestUtilsUseCase.CreateUnsavedDefaultUseCase();
            //---------------Assert Precondition----------------
            useCase.PointsAssigned = TestUtils.GetRandomInt(0,50);
            Assert.IsNull(useCase.PointsBaseline);
            //---------------Execute Test ----------------------
           useCase.SetBaseline();
            //---------------Test Result -----------------------
           Assert.AreEqual(null, useCase.PointsBaseline);
        }

       [Test]
       public void Test_SetBaseline_UseCase_BelongsToDrop()
       {
           //---------------Set up test pack-------------------
           UseCase useCase = TestUtilsUseCase.CreateUnsavedValidUseCase();
           Drop drop = TestUtilsDrop.CreateUnsavedValidDrop();
           drop.UseCases.Add(useCase);
           drop.Save();
           useCase.Save();
           //---------------Assert Precondition----------------
           useCase.PointsAssigned = TestUtils.GetRandomInt(0, 50);
           Assert.IsNull(useCase.PointsBaseline);
           //---------------Execute Test ----------------------
           useCase.SetBaseline();
           //---------------Test Result -----------------------
           Assert.AreEqual(useCase.PointsAssigned, useCase.PointsBaseline);
       }

        [Test]
        public void Test_ToString()
        {
            //---------------Set up test pack-------------------
            UseCase useCase = TestUtilsUseCase.CreateUnsavedValidUseCase();
            //---------------Assert Precondition----------------
            
            //---------------Execute Test ----------------------
            string actualToString = useCase.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(useCase.Package + "- " + useCase.UseCaseName + "(UC" + useCase.UseCaseNumber + ") - " +"A"+ useCase.PointsAssigned+" B"+useCase.PointsBaseline, actualToString);
        }
    }
}